﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using ViewModel;

namespace StockDisplay
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        MainWindowViewModel mainWindowView;

        /// <summary>
        /// Overriden OnStartup method that creates the initial ViewModel
        /// and binds it to the main window
        /// </summary>
        /// <param name="e"></param>
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            MainWindow window = new MainWindow();

            mainWindowView = new MainWindowViewModel();
            mainWindowView.OnStartup();

            window.DataContext = mainWindowView;

            window.Show();
        }

        /// <summary>
        /// Overriden OnExit - Cleans up any resources
        /// </summary>
        /// <param name="e"></param>
        protected override void OnExit(ExitEventArgs e)
        {
            mainWindowView.Dispose();

            base.OnExit(e);
        }
    }
}
